Happy Number Calculator

A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits in base-ten, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers). The repeating loop that all unhappy numbers fall into is 4, 16, 37, 58, 89, 145, 42, 20, 4.

Rearranging the digits of a happy number produces another happy number, as does inserting any number of zeroes.

The calculator returns either a list of happy numbers up to the limit input by the user or checks to see whether the number input is happy.

The limit is based solely on your patience. A limit of 1,000,000 takes about a 4 seconds to calculate. But scrolling through the list of 71,599 happy numbers takes significantly longer.




Enter a number and hit the button: